From 68d7e6a21060865ab8bfd47d5d20418d592e246d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Mon, 26 Sep 2005 21:58:17 +0000 Subject: [PATCH] profiling on demand --- ChangeLog | 26 ++++++++++++++++++++++++++ babl/babl-classes.h | 7 ++++--- babl/babl-format.c | 38 +++++++++++++++++--------------------- babl/babl-internal.c | 42 +----------------------------------------- babl/babl-internal.h | 7 ++++--- babl/babl-type.c | 5 +++++ babl/babl-util.c | 21 +++++++++++++++++++++ babl/babl-util.h | 7 +++++++ 8 files changed, 85 insertions(+), 68 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62c5cce..4b4fcbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2005-09-27 Øyvind Kolås + + * babl/babl-util.h, + * babl/babl-util.c: (babl_rel_avg_error): moved buffer comparison + function to one place. + * babl/babl-classes.h: Added error field to fishes, made path length + dynamic. + * babl/babl-internal.h: added misc global constants. + * babl/babl-internal.c: created caching accessors in classes, to avoid + very large bootstrapping time. + * babl/babl-conversion.c: (test_create), (babl_conversion_cost), + (babl_conversion_error): + * babl/babl-format.c: (test_create), (babl_format_loss): + * babl/babl-type.c: (babl_type_is_symmetric): + +2005-09-27 Øyvind Kolås + + Moved html generator stats code into a seperate source fil in core, + babl now creates /tmp/babl-stats.txt when the BABL_STATS enviroment + variable is set. + + * babl/Makefile.am: + * babl/babl.c: + * tests/babl_fish_path_dhtml.c: (main): + * babl/babl-fish-stats.c: (table_destination_each). + 2005-09-19 Øyvind Kolås * docs/index-static.html.in: s/DHTML/interactive/ diff --git a/babl/babl-classes.h b/babl/babl-classes.h index 007ba97..e7ab444 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -201,8 +201,9 @@ typedef struct BablInstance instance; union Babl *source; union Babl *destination; - int processings; - long pixels; + int processings; + long pixels; + double error; } BablFish; @@ -232,7 +233,7 @@ typedef struct BablFish fish; double cost; double loss; - BablConversion *conversion[BABL_MAX_PATH_LENGTH]; + BablConversion *conversion[BABL_HARD_MAX_PATH_LENGTH]; int conversions; } BablFishPath; diff --git a/babl/babl-format.c b/babl/babl-format.c index 4881b04..0dae68f 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -336,7 +336,7 @@ babl_format_with_model_as_type (Babl *model, ); } -#define pixels 256 +#define test_pixels 256 static double * test_create (void) @@ -346,9 +346,9 @@ test_create (void) srandom (20050728); - test = babl_malloc (sizeof (double) * pixels * 4); + test = babl_malloc (sizeof (double) * test_pixels * 4); - for (i = 0; i < pixels * 4; i++) + for (i = 0; i < test_pixels * 4; i++) test [i] = (double) random () / RAND_MAX; return test; @@ -386,27 +386,23 @@ babl_format_loss (Babl *babl) fish_from = babl_fish_reference (fmt, ref_fmt); test = test_create (); - original = babl_calloc (pixels, fmt->format.bytes_per_pixel); - clipped = babl_calloc (pixels, ref_fmt->format.bytes_per_pixel); - destination = babl_calloc (pixels, fmt->format.bytes_per_pixel); - transformed = babl_calloc (pixels, ref_fmt->format.bytes_per_pixel); + original = babl_calloc (test_pixels, fmt->format.bytes_per_pixel); + clipped = babl_calloc (test_pixels, ref_fmt->format.bytes_per_pixel); + destination = babl_calloc (test_pixels, fmt->format.bytes_per_pixel); + transformed = babl_calloc (test_pixels, ref_fmt->format.bytes_per_pixel); - babl_process (fish_to, test, original, pixels); - babl_process (fish_from, original, clipped, pixels); - babl_process (fish_to, clipped, destination, pixels); - babl_process (fish_from, destination, transformed, pixels); + babl_process (fish_to, test, original, test_pixels); + babl_process (fish_from, original, clipped, test_pixels); + babl_process (fish_to, clipped, destination, test_pixels); + babl_process (fish_from, destination, transformed, test_pixels); - { - int i; - - for (i=0;ifish.processings-=2; + fish_from->fish.processings-=2; + fish_to->fish.pixels-=test_pixels*2; + fish_from->fish.pixels -= test_pixels*2; + babl_free (original); babl_free (clipped); babl_free (destination); diff --git a/babl/babl-internal.c b/babl/babl-internal.c index 555f672..ae7bc26 100644 --- a/babl/babl-internal.c +++ b/babl/babl-internal.c @@ -17,6 +17,7 @@ * Boston, MA 02111-1307, USA. */ +#include #include "babl-internal.h" static const char *class_names[] = @@ -124,44 +125,3 @@ babl_name (Babl *babl) babl_assert (BABL_IS_BABL (babl)); return babl->instance.name; } - -static int -each_conversion (Babl *babl, - void *user_data) -{ - babl_conversion_error (&babl->conversion); - return 0; -} - -static int -each_format (Babl *babl, - void *user_data) -{ - babl_format_loss (babl); - return 0; -} - -static int -gen_type_format_for_model (Babl *type, void *userdata) -{ - babl_format_with_model_as_type (userdata, type); - return 0; -} - -static int -gen_formats_for_model (Babl *model, void *userdata) -{ - babl_type_each (gen_type_format_for_model, model); - return 0; -} - -void -babl_extension_post_load (void) -{ - babl_conversion_each (each_conversion, NULL); - babl_format_each (each_format, NULL); - return; - babl_model_each (gen_formats_for_model, NULL); - babl_format_each (each_format, NULL); -} - diff --git a/babl/babl-internal.h b/babl/babl-internal.h index 6f0973e..376cb6f 100644 --- a/babl/babl-internal.h +++ b/babl/babl-internal.h @@ -24,8 +24,8 @@ #error babl-internal.h included after babl.h #endif -#define BABL_MAX_COMPONENTS 32 -#define BABL_MAX_PATH_LENGTH 5 +#define BABL_MAX_COMPONENTS 32 +#define BABL_HARD_MAX_PATH_LENGTH 8 #include #include @@ -48,13 +48,13 @@ Babl * babl_conversion_find (void *source, void *destination); double babl_conversion_error (BablConversion *conversion); +long babl_conversion_cost (BablConversion *conversion); long babl_conversion_process (Babl *conversion, void *source, void *destination, long n); Babl * babl_extension_base (void); -void babl_extension_post_load (void); Babl * babl_extender (void); void babl_set_extender (Babl *new_extender); @@ -74,6 +74,7 @@ BablDb * babl_fish_db (void); Babl * babl_fish_reference (Babl *source, Babl *destination); Babl * babl_fish_simple (BablConversion *conversion); +void babl_fish_stats (FILE *file); Babl * babl_fish_path (Babl *source, Babl *destination); diff --git a/babl/babl-type.c b/babl/babl-type.c index 81d270e..e04e97d 100644 --- a/babl/babl-type.c +++ b/babl/babl-type.c @@ -213,6 +213,11 @@ babl_type_is_symmetric (Babl *babl) babl_process (fish_to, clipped, destination, samples); babl_process (fish_from, destination, transformed, samples); + fish_from->fish.processings-=2; + fish_to->fish.processings-=2; + fish_from->fish.pixels -= samples*2; + fish_to->fish.pixels -= samples*2; + { int cnt=0; int i; diff --git a/babl/babl-util.c b/babl/babl-util.c index 182f5e3..63284fb 100644 --- a/babl/babl-util.c +++ b/babl/babl-util.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "babl-memory.h" #include "babl-internal.h" @@ -100,3 +101,23 @@ babl_ticks (void) gettimeofday (&measure_time, NULL); return msecs(measure_time) - msecs(start_time); } + +double +babl_rel_avg_error (double *imgA, + double *imgB, + long samples) +{ + double error = 0.0; + int i; + + for (i=0; i= 0.000001) + error /= samples; + else + error = 0.0; + + return error; +} + diff --git a/babl/babl-util.h b/babl/babl-util.h index 9fa1176..be6c9bc 100644 --- a/babl/babl-util.h +++ b/babl/babl-util.h @@ -20,6 +20,8 @@ #ifndef _BABL_UTIL_H #define _BABL_UTIL_H +#include + void babl_add_ptr_to_list (void ***list, void *new); @@ -29,4 +31,9 @@ babl_list_each (void **list, void *user_data); unsigned int babl_ticks (void); + +double +babl_rel_avg_error (double *imgA, + double *imgB, + long samples); #endif -- 2.30.2